class AparelhosController < ApplicationController
  respond_to :html, :json


  def index
    @aparelhos = Aparelho.find(:all, :include => :cliente)
    respond_with @aparelhos
  end

  def show
    @aparelho = Aparelho.find(params[:id], :include => :cliente)
    respond_with @aparelho
  end


  def new
    @aparelho = Aparelho.new
    respond_with :aparelho
  end


  def edit
    @aparelho = Aparelho.find(params[:id], :include => :cliente)
  end

  def create
    @aparelho = Aparelho.new(params[:aparelho])

    respond_to do |format|
      if @aparelho.save
        format.html { redirect_to @aparelho, notice: 'Aparelho was successfully created.' }
        format.json { render json: @aparelho, status: :created, location: @aparelho }
      else
        format.html { render action: "new" }
        format.json { render json: @aparelho.errors, status: :unprocessable_entity }
      end
    end
  end

  def update
    @aparelho = Aparelho.find(params[:id])

    respond_to do |format|
      if @aparelho.update_attributes(params[:aparelho])
        format.html { redirect_to @aparelho, notice: 'Aparelho was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @aparelho.errors, status: :unprocessable_entity }
      end
    end
  end

  def destroy
    @aparelho = Aparelho.find(params[:id])
    @aparelho.destroy
    respond_with @aparelho
  end


end
